package com.jeesite.modules.stock.web;


import com.jeesite.common.entity.Page;
import com.jeesite.common.web.ResponseData;
import com.jeesite.modules.stock.dto.StockDateRangeRankSearchDTO;
import com.jeesite.modules.stock.dto.StockSearchDTO;
import com.jeesite.modules.stock.dto.vo.StockHistoryDataVO;
import com.jeesite.modules.stock.service.StockDailyService;
import com.jeesite.modules.stock.service.UserRequestLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 股票controller
 */
@RestController
@RequestMapping("${adminPath}/stock")
public class StockDailyController {

    @Autowired
    private StockDailyService stockDailyService;



    /**
     * 获取所有股票
     *
     */
    @PostMapping("getStocks")
    @ResponseBody
    public ResponseData<Page<Map<String, Object>>> getStocks(@RequestBody StockSearchDTO stockSearchDTO) {
        return stockDailyService.findStocks(stockSearchDTO);

    }

    /**
     * 查询单只股票
     *
     * @param stockCode 股票代码
     */
    @GetMapping("getStock/{stockCode}")
    public Map<String, Object> getStock(@PathVariable String stockCode) {
        return stockDailyService.findStockByStockCode(stockCode);
    }

    /**
     * 按时间查询股票区间排名
     *
     * @param searchDTO 查询条件
     */
    @PostMapping("getStocksOfDateRange")
    public Page<StockHistoryDataVO> getStocksOfDateRange(@RequestBody StockDateRangeRankSearchDTO searchDTO) {
        return stockDailyService.findDateRangeRank(searchDTO);
    }

    @GetMapping("getStockAiRecommendStockList/{stockCode}")
    public List<Map<String, Object>> getStockAiRecommendStockList(@PathVariable String stockCode) {
        return stockDailyService.getStockAiRecommendStockList(stockCode);
    }
}
